const merge = require('webpack-merge');
process.env.NODE_ENV = 'development'
const common = require('./webpack.common.js');
const path = require('path');
const webpack = require('webpack');
const webpackConfigDev =  {
  mode: 'development',
  devtool: 'inline-source-map', // 定位错误文件
  // devServer: {
  //   contentBase: path.join(__dirname, "./src") // 配置告知 webpack-dev-server，将 dist 目录下的文件 serve 到 localhost:8080 
  // }
  output: {
    path: path.resolve(__dirname, 'dist'),
    // 打包多出口文件
    filename: './js/[name].bundle.js'
  },
  devServer: {
    // contentBase: './dist', // 配置告知 webpack-dev-server，将 dist 目录下的文件 serve 到 localhost:8080 
    // compress: true,
    contentBase: path.join(__dirname, './src/pages/index'),
    publicPath: '/',
    host: "127.0.0.1",
    port: "8090",
    inline: true,
    hot: true, // 开启热更新
    //服务器代理配置项处理跨域问题
    // proxy: {
    //     '/test/*':{
    //         target: 'https://www.baidu.com',
    //         secure: true,
    //         changeOrigin: true
    //     }
    // }
  },
  plugins: [
    //热更新
    new webpack.HotModuleReplacementPlugin(),
    new webpack.DefinePlugin({
      // DefinePlugin 允许创建一个在编译时可以配置的全局常量
      'process.env.BASE_URL': JSON.stringify('development')
    })
  ],
  devtool: 'source-map',  // 开启调试模式
}
module.exports = merge(common, webpackConfigDev);